package com.czxy.dem01;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;

public class Test07 {

    public static void main(String[] args) {
        //定义随机数和键盘录入
        Random rd = new Random();
        Scanner sc = new Scanner(System.in);
        //集合用来存储发的牌
        List<Integer> list = new ArrayList<>();
        int sum = 0;
        int count = 0;
        while (true) {
            System.out.println("1.发牌");
            System.out.println("2.结束发牌");
            int i = sc.nextInt();
            int i1 = rd.nextInt(13);
            if (i==1) {
                sum+=i1;
                count++;
                list.add(i1);
                if (sum <= 21) {
                    System.out.println("您手上的牌是："+list+"点数为："+sum);
                }else {
                    System.out.println("点数为："+sum+"大于21点游戏结束");
                    break;
                }
            }else {
                System.out.println("您手上的牌是："+list+"点数为："+sum);
                break;
            }
        }
    }
}
